﻿<UserControl x:Class="TV_Organizer.PreferencesControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:mwc="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
             xmlns:tvofs="clr-namespace:TV_Organizer.FileScanner"
             xmlns:tvop="clr-namespace:TV_Organizer.Properties"
             xmlns:local="clr-namespace:TV_Organizer.Preferences">
  <UserControl.Resources>
    <Style x:Key="CategoryHeaderTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
      <Setter Property="FontSize" Value="16" />
      <Setter Property="FontWeight" Value="DemiBold" />
      <!--<Setter Property="HorizontalAlignment" Value="Center" />-->
      <Setter Property="Margin" Value="5,20,5,5" />
    </Style>
  </UserControl.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TabControl>
      <!--  GENERAL  -->
      <TabItem HorizontalContentAlignment="Left" Header="General">
        <StackPanel>
          <Button Name="ResetSettings" Click="ResetSettings_Click">Reset all settings</Button>
        </StackPanel>
      </TabItem>

      <TabItem HorizontalContentAlignment="Left" Header="Folders">
        <StackPanel>
          <!--  Folders to scan  -->
          <TextBlock HorizontalAlignment="Center">Folders to scan :</TextBlock>
          <ListView Name="FoldersToScanListView" ItemsSource="{Binding Path=FoldersToScan, Source={x:Static tvofs:FileScanner.Instance}}" />
          <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
            <Button Name="AddFolderToScanButton" Click="AddFolderToScanButton_Click">Add</Button>
            <Button Name="DeleteFolderToScanButton" Click="DeleteFolderToScanButton_Click">Delete</Button>
          </StackPanel>
          <Separator />

        </StackPanel>
      </TabItem>

      <!--  Renaming/Moving  -->
      <TabItem HorizontalContentAlignment="Left" Header="Renaming/Moving">
        <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
          <StackPanel>
            <StackPanel Orientation="Horizontal">
              <TextBox Margin="5" VerticalAlignment="Center" Text="{Binding Path=MaxDepth, Source={x:Static tvop:Settings.Default}}" />
              <TextBlock VerticalAlignment="Center">Maximum depth of scan</TextBlock>
            </StackPanel>

            <!-- ANALYSIS -->
            <TextBlock>Analysis</TextBlock>
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Apply XviD tag to .avi files" IsChecked="{Binding Path=ApplyXviDToAVI, Source={x:Static tvop:Settings.Default}}" />
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Apply 720p tag to .mkv files" IsChecked="{Binding Path=Apply720pToMKV, Source={x:Static tvop:Settings.Default}}" />
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Apply x264 tag to .mkv files" IsChecked="{Binding Path=ApplyX264ToMKV, Source={x:Static tvop:Settings.Default}}" />
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Apply HDTV tag" IsChecked="{Binding Path=ApplyHDTV, Source={x:Static tvop:Settings.Default}}" />

            <!-- RENAMING -->
            <TextBlock Style="{StaticResource CategoryHeaderTextBlockStyle}">Renaming</TextBlock>
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Include language at the end of subtitles file names" IsChecked="{Binding Path=IncludeLanguageInSubtitlesFileNames, Source={x:Static tvop:Settings.Default}}" />
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Apply " IsChecked="{Binding Path=IncludeLanguageInSubtitlesFileNames, Source={x:Static tvop:Settings.Default}}" />

            <!-- MOVING -->
            <TextBlock Style="{StaticResource CategoryHeaderTextBlockStyle}">Moving</TextBlock>
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Move TV Shows files after renaming" IsChecked="{Binding Path=MoveTvShows, Source={x:Static tvop:Settings.Default}}" />
            <StackPanel Orientation="Horizontal">
              <StackPanel.Style>
                <Style TargetType="StackPanel">
                  <Setter Property="IsHitTestVisible" Value="True" />
                  <Setter Property="Opacity" Value="1.0" />
                  
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=MoveTvShows, Source={x:Static tvop:Settings.Default}}" Value="False">
                      <Setter Property="IsHitTestVisible" Value="False" />
                      <Setter Property="Opacity" Value="0.5" />
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </StackPanel.Style>

              <TextBlock Margin="5" Text="Target folder:" VerticalAlignment="Center" />
              <TextBox Margin="5" Width="500" Text="{Binding Path=TVShowsFolder, Source={x:Static tvop:Settings.Default}}" VerticalContentAlignment="Center" />
              <Button Margin="5" Name="TVShowsFolderButton" Click="TVShowsFolderButton_Click">...</Button>
            </StackPanel>
            <CheckBox Margin="5" VerticalAlignment="Center" Content="Remove empty direcories after move" IsChecked="{Binding Path=RemoveEmptyDirectories, Source={x:Static tvop:Settings.Default}}" />

            <!-- FOLDERS FORMAT -->
            <StackPanel Orientation="Horizontal">
              <TextBlock Margin="5" Text="Folders format:" VerticalAlignment="Center" />
              <TextBox Margin="5" Width="500" Text="{Binding Path=TVShowFolderPath, Source={x:Static tvop:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" />
              <Button Margin="5" Click="ResetTVShowFolderPathButton_Click" Content="Reset" />
            </StackPanel>
            <TextBlock Margin="5" FontStyle="Italic">
              <Run Text="Preview: " />
              <Run Text="{Binding Path=TVShowFolderPath, Source={x:Static tvop:Settings.Default}, Converter={x:Static local:TVShowFolderPathPreviewConverter.Instance}}" />
            </TextBlock>
            <TextBlock Margin="5" x:Name="TVShowFolderPathDescription" TextWrapping="Wrap" />
          </StackPanel>
        </ScrollViewer>
      </TabItem>

      <!--  Automation  -->
      <TabItem HorizontalContentAlignment="Left" Header="Automation">
        <StackPanel>
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Start minized (consumes less RAM)"                  IsChecked="{Binding Path=StartMinimized, Source={x:Static tvop:Settings.Default}}" />
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Disable notifications (silent mode)"                IsChecked="{Binding Path=DisableNotifications, Source={x:Static tvop:Settings.Default}}" />

          <Separator />
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Automatically analyze loaded files"                 IsChecked="{Binding Path=AnalyzeFilesAfterLoad, Source={x:Static tvop:Settings.Default}}" />
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Automatically rename analyzed files"                IsChecked="{Binding Path=ProcessFilesAfterAnalyze, Source={x:Static tvop:Settings.Default}}" />
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Automatically download subtitles for renamed files" IsChecked="{Binding Path=DownloadSubtitlesAfterProcess, Source={x:Static tvop:Settings.Default}}" />

          <Separator />
          <CheckBox Margin="5" VerticalAlignment="Center" Content="Automatically load files added to watched folders" IsChecked="{Binding Path=FileSystemWatch, Source={x:Static tvop:Settings.Default}}" />

        </StackPanel>
      </TabItem>

      <!--  SOURCES  -->
      <TabItem HorizontalContentAlignment="Left" Header="Sources">
        <StackPanel>
          <!--  EP Guides  -->
          <TextBlock>
            <Run>TV shows list from EPGuides.com :</Run>
            <Run Text="{Binding Path=EPGuidesShows.Count, Source={x:Static tvop:Settings.Default}, Mode=OneWay}" />
            <Run>shows</Run>
          </TextBlock>
          <Button Name="UpdateEPGuidesButton" Click="UpdateEPGuidesButton_Click">Update</Button>

          <Button Name="EditTeamsButton" Click="EditTeamsButton_Click">Edit Teams</Button>
        </StackPanel>
      </TabItem>
    </TabControl>
  </Grid>
</UserControl>
